/**
 * 
 */
package com.nars.arrays.examples;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * @author Student
 * 
 */
public class ArrayFromCommandLine {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);
		Random random = new Random();

		System.out.println("Enter N: ");
		int n = input.nextInt();
		System.out.println("Enter k: ");
		int k = input.nextInt();

		int[] arrayInt = new int[n];

		for (int i = 0; i < arrayInt.length; i++) {
			arrayInt[i] = random.nextInt(100);
		}

		System.out.println(Arrays.toString(arrayInt));
		Arrays.sort(arrayInt);
		System.out.println(Arrays.toString(arrayInt));
		System.out.println("The largest position of " + k + " is '"
				+ Arrays.binarySearch(arrayInt, k) + "'");
	}

}
